<html  xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"/>
    <title>dati</title>

    <meta http-equiv="X-UA-Compatible" content="IE=Edge"/>

    <script src="/js/common.js"></script>
</head>
<body>
<style>
    body{
        background-image: url("/static/images/background.jpeg");
        background-position: center 0;
        background-repeat: no-repeat;
        background-attachment: fixed;
        background-size: cover;
        -webkit-background-size: cover;
        -o-background-size: cover;
        -moz-background-size: cover;
        -ms-background-size: cover;
    }
    .container{
        max-width: 1000px;
        background-color: transparent;
        min-height: 100%;
    }

</style>

<script src="/js/common.js"></script>
<script src="https://cdn.jsdelivr.net/vue.resource/1.2.1/vue-resource.min.js"></script>
<script src="https://cdn.bootcss.com/vue-router/3.0.1/vue-router.js"></script>
<div class="container" id="app" style="max-width: 1000px">


    <div class="post">
        <table class="table table-hover">
            <tr class="text-center">
                <td>订单号</td>
                <td>下单时间</td>
                <td>消防器材名称</td>
                <td>规格</td>
                <td>价钱</td>
                <td>状态</td>
                <td>操作</td>
            </tr>
            <tr v-for="(item, i) in items" class="text-center">
                <td>{{item.billID}}</td>
                <td>{{item.billTime}}</td>
                <td>{{item.freshName}}</td>
                <td>{{item.freshSize}}</td>
                <td>{{item.freshPrice}}</td>
                <td>{{item.billState}}</td>
                <td>
                    <button type="button" class="btn btn-info" v-if="item.billState=='已发货'" v-on:click="takeOf(item.billID);">确认收货</button>
                    <button type="button" class="btn btn-info" v-if="item.billState=='已发货'" v-on:click="reject(item.billID);">退货</button>
                    <button type="button" class="btn btn-info" v-if="item.billState=='已发货'" v-on:click="info(item.billID,item.logistics,item.logisticsID,item.company);">查看物流信息</button>
                    <button type="button" class="btn btn-info" v-if="item.billState=='未付款'" v-on:click="pay(item.billID);">付款</button>
                    <button type="button" class="btn btn-danger" v-if="item.billState=='未付款'" v-on:click="cancel(item.billID);">取消</button>
                    <button type="button" class="btn btn-info" v-if="item.billState=='已收货'" v-on:click="comment(item.billID);">评价</button>
                </td>
            </tr>
        </table>
    </div>

    <!--  </div>-->
</div>
<script>

    var app = new Vue({
        el: '#app',
        data: {
            count:0,
            items: [
            ]
        },
        methods: {
            takeOf:function (billID) {
                var params={
                    billID:billID
                };
                $.ajax({
                    type : "post",
                    url : "/user/takeOf",
                    data : params,
                    success : function(data) {
                        if(data.code==200){
                            alert("收货成功");
                            location.reload();
                        }
                        else if(data.code==404){
                            alert("未登录");
                            location.href="/";
                        }
                        else {
                            alert("连接错误");
                        }
                    }
                });
            },
            pay:function (billID) {
                var params={
                    billID:billID
                };
                $.ajax({
                    type : "post",
                    url : "/user/pay",
                    data : params,
                    success : function(data) {
                        if(data.code==200){
                            alert("付款成功");
                            location.reload();
                        }
                        else if(data.code==404){
                            alert("未登录");
                            location.href="/";
                        }
                        else {
                            alert("连接错误");
                        }
                    }
                });
            },
            cancel:function (billID) {
                var params={
                    billID:billID
                };
                $.ajax({
                    type : "post",
                    url : "/user/cancel",
                    data : params,
                    success : function(data) {
                        if(data.code==200){
                            alert("取消成功");
                            location.reload();
                        }
                        else if(data.code==404){
                            alert("未登录");
                            location.href="/";
                        }
                        else {
                            alert("连接错误");
                        }
                    }
                });
            },
            reject:function (billID) {
                var params={
                    billID:billID
                };
                $.ajax({
                    type : "post",
                    url : "/user/reject",
                    data : params,
                    success : function(data) {
                        if(data.code==200){
                            alert("退货成功");
                            location.reload();
                        }
                        else if(data.code==404){
                            alert("未登录");
                            location.href="/";
                        }
                        else {
                            alert("连接错误");
                        }
                    }
                });
            },
            comment:function (billID) {
                window.location.href='/comment?billID='+billID;
            },
            info: function (billID,logistics,logisticsID,company) {
                window.location.href='/toLogisticsInfo?billID='+billID+"&logistics="+logistics+"&logisticsID="+logisticsID+"&company="+company;
            },
        }
    });
    $(document).ready(function(){
        var params1=[]
        $.ajax({
            type : "post",
            url : "/user/showBillList",
            data : params1,
            success : function(data) {
                app.items=data.carList;
                app.count=data.count;
                if(data.code==404){
                    alert("未登录");
                    location.href="/";
                }
            }
        });
    })
</script>
</body>
</html>
